//
//  WPTabViewController.m
//  CaiPiao
//
//  Created by zhoup on 16/5/24.
//  Copyright © 2016年 zhoup. All rights reserved.
//

#import "WPTabViewController.h"

#import "HistoryViewController.h"
#import "DiscoveryViewController.h"
#import "ArenaViewController.h"
#import "SettingViewController.h"
#import "HallViewController.h"

#import "WPTabbar.h"

@interface WPTabViewController ()<WPTabbarDelegate>

@end

@implementation WPTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    WPTabbar *tabbar = [[WPTabbar alloc]init];
    [tabbar setBackgroundColor:[UIColor blackColor]];
    tabbar.frame = self.tabBar.bounds;
    tabbar.delegate = self;
    [self.tabBar addSubview:tabbar];
/*
    HistoryViewController *historyVc =[[HistoryViewController alloc]init];
    
    UINavigationController *navHistroyVc = [[UINavigationController alloc]initWithRootViewController:historyVc];
 
    DiscoveryViewController *discoveryVc =[[DiscoveryViewController alloc]init];
    
    UINavigationController *navDiscoverVc = [[UINavigationController alloc]initWithRootViewController:discoveryVc];
    
    ArenaViewController *arenaVc =[[ArenaViewController alloc]init];
    
    SettingViewController *settingVc =[[SettingViewController alloc]init];
    HallViewController *hallVc =[[HallViewController alloc]init];
    
    self.viewControllers = @[navHistroyVc,navDiscoverVc,arenaVc,settingVc,hallVc];
 
 */
    [self addMychildController:@"Hall"];
    [self addMychildController:@"ArenaView"];
    [self addMychildController:@"Discovery"];
    [self addMychildController:@"History"];
    [self addMychildController:@"SettingView"];
    
}


-(void)addMychildController:(NSString *)name
{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:name bundle:nil];
    
    UIViewController *rootVc = [sb instantiateInitialViewController];
    
    
//    rootVc.tabBarItem.title = @"xx";
//    rootVc.tabBarItem.image = [UIImage imageNamed:@"TabBar_Arena"];
//    rootVc.tabBarItem.selectedImage = [UIImage imageNamed:@"TabBar_Arena_selected"];
    
    [self addChildViewController:rootVc];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)tabbar:(WPTabbar *)tabbar fromTag:(NSInteger)from toTag:(NSInteger)to
{
    self.selectedIndex = to;
    
}


@end
